<?php if (!defined('THINK_PATH')) exit();?>
<!-- 字段未设置编辑权限或当前用户在编辑权限内 -->
<?php if(!$formData['member_id'] || in_array($index['member_id'],explode(',',$formData['member_id']))): switch($formData["form_type"]): case "text": ?><input type="text" name="<?php echo ($formType); ?>_form[<?php echo ($formData["form_name"]); ?>]" value="<?php echo ($dataInfo['detail'][$formData['form_name']]); ?>" class="layui-input" />

		<script>

			$('input[name="<?php echo ($formType); ?>_form[<?php echo ($formData["form_name"]); ?>]"]').blur(function()
			{
				var content = $(this).val();

				//updateFormContentAjax('<?php echo U("AjaxRequest/updateFormContent");?>','<?php echo ($infoId); ?>','<?php echo ($formType); ?>',content,'<?php echo ($formData["form_name"]); ?>',$('input[name="<?php echo ($formType); ?>_form[<?php echo ($formData["form_name"]); ?>]"]'));
			})

		</script><?php break;?>

	<?php case "phone": ?><input type="text" onKeyPress="if (event.keyCode!=46 && event.keyCode!=45 && event.keyCode<48 || event.keyCode>57) event.returnValue=false" name="<?php echo ($formType); ?>_form[<?php echo ($formData["form_name"]); ?>]" value="<?php echo ($dataInfo['detail'][$formData['form_name']]); ?>" class="layui-input" />

		<script>

			$('input[name="<?php echo ($formType); ?>_form[<?php echo ($formData["form_name"]); ?>]"]').blur(function()
			{
				var content = $(this).val();

				//updateFormContentAjax('<?php echo U("AjaxRequest/updateFormContent");?>','<?php echo ($infoId); ?>','<?php echo ($formType); ?>',content,'<?php echo ($formData["form_name"]); ?>',$('input[name="<?php echo ($formType); ?>_form[<?php echo ($formData["form_name"]); ?>]"]'));
			})

		</script><?php break;?>

	<?php case "email": ?><input type="text" name="<?php echo ($formType); ?>_form[<?php echo ($formData["form_name"]); ?>]" value="<?php echo ($dataInfo['detail'][$formData['form_name']]); ?>" class="layui-input" />

		<script>

			$('input[name="<?php echo ($formType); ?>_form[<?php echo ($formData["form_name"]); ?>]"]').blur(function()
			{
				var content = $(this).val();

				//updateFormContentAjax('<?php echo U("AjaxRequest/updateFormContent");?>','<?php echo ($infoId); ?>','<?php echo ($formType); ?>',content,'<?php echo ($formData["form_name"]); ?>',$('input[name="<?php echo ($formType); ?>_form[<?php echo ($formData["form_name"]); ?>]"]'));
			})

		</script><?php break;?>

	<?php case "number": ?><input type="number" onKeyPress="if (event.keyCode!=46 && event.keyCode!=45 && event.keyCode<48 || event.keyCode>57) event.returnValue=false" name="<?php echo ($formType); ?>_form[<?php echo ($formData["form_name"]); ?>]" value="<?php echo ($dataInfo['detail'][$formData['form_name']]); ?>" class="layui-input" />

		<script>

			$('input[name="<?php echo ($formType); ?>_form[<?php echo ($formData["form_name"]); ?>]"]').blur(function()
			{
				var content = $(this).val();

				//updateFormContentAjax('<?php echo U("AjaxRequest/updateFormContent");?>','<?php echo ($infoId); ?>','<?php echo ($formType); ?>',content,'<?php echo ($formData["form_name"]); ?>',$('input[name="<?php echo ($formType); ?>_form[<?php echo ($formData["form_name"]); ?>]"]'));
			})

		</script><?php break;?>

	<?php case "decimal": ?><input type="text" name="<?php echo ($formType); ?>_form[<?php echo ($formData["form_name"]); ?>]" value="<?php echo ($dataInfo['detail'][$formData['form_name']]); ?>" class="layui-input" />

		<script>

			$('input[name="<?php echo ($formType); ?>_form[<?php echo ($formData["form_name"]); ?>]"]').blur(function()
			{
				var content = $(this).val();

				//updateFormContentAjax('<?php echo U("AjaxRequest/updateFormContent");?>','<?php echo ($infoId); ?>','<?php echo ($formType); ?>',content,'<?php echo ($formData["form_name"]); ?>',$('input[name="<?php echo ($formType); ?>_form[<?php echo ($formData["form_name"]); ?>]"]'));
			})

		</script><?php break;?>

	<?php case "date": ?><input type='text' name="<?php echo ($formType); ?>_form[<?php echo ($formData["form_name"]); ?>]" value="<?php echo ($dataInfo['detail'][$formData['form_name']]); ?>" class="layui-input cursor layui-form-time" id="form_type_time<?php echo $ft; ?>" placeholder="<?php echo L('SELECT_TIME');?>" >

		<script>

			layui.use(['laydate'],function()
			{
				var laydate = layui.laydate;

				laydate.render({
					elem: '#form_type_time<?php echo ($ft); ?>',
					type: 'datetime',
					trigger: 'click',
					done: function(value, date)
					{
						//updateFormContentAjax('<?php echo U("AjaxRequest/updateFormContent");?>','<?php echo ($infoId); ?>','<?php echo ($formType); ?>',value,'<?php echo ($formData["form_name"]); ?>',$('input[name="<?php echo ($formType); ?>_form[<?php echo ($formData["form_name"]); ?>]"]'));
					}
				});
			})

		</script><?php break;?>

	<?php case "checkbox": if(is_array($formData["option"])): $i = 0; $__LIST__ = $formData["option"];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$op): $mod = ($i % 2 );++$i;?><input type="checkbox" name="<?php echo ($formType); ?>_form[<?php echo ($formData["form_name"]); ?>][]" value="<?php echo ($op); ?>" title="<?php echo ($op); ?>" <?php if(in_array(($op), is_array($dataInfo['detail'][$formData[form_name]])?$dataInfo['detail'][$formData[form_name]]:explode(',',$dataInfo['detail'][$formData[form_name]]))): ?>checked<?php endif; ?> lay-skin="primary" lay-filter="checkbox-filter<?php echo ($t); ?>" /><?php endforeach; endif; else: echo "" ;endif; ?>

		<script >

			layui.use(['form'],function()
			{
				var form = layui.form;

				form.on('checkbox(checkbox-filter<?php echo ($t); ?>)', function(data)
				{
					var content = [];

					$('input[name="<?php echo ($formType); ?>_form[<?php echo ($formData["form_name"]); ?>][]"]:checked').each(function()
					{
						content.push($(this).val());
					});

					//updateFormContentAjax('<?php echo U("AjaxRequest/updateFormContent");?>','<?php echo ($infoId); ?>','<?php echo ($formType); ?>',content,'<?php echo ($formData["form_name"]); ?>',$('input[name="<?php echo ($formType); ?>_form[<?php echo ($formData["form_name"]); ?>][]"]'));

				})
			})

		</script><?php break;?>

	<?php case "radio": if(is_array($formData["option"])): $i = 0; $__LIST__ = $formData["option"];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$op): $mod = ($i % 2 );++$i;?><input type="radio" name="<?php echo ($formType); ?>_form[<?php echo ($formData["form_name"]); ?>]" <?php if(($dataInfo['detail'][$formData[form_name]]) == $op): ?>checked<?php endif; ?> value="<?php echo ($op); ?>" title="<?php echo ($op); ?>" lay-filter="radio-filter<?php echo ($t); ?>"><?php endforeach; endif; else: echo "" ;endif; ?>

		<script >

			layui.use(['form'],function()
			{
				var form = layui.form;

				form.on('radio(radio-filter<?php echo ($t); ?>)', function(data)
				{
					//updateFormContentAjax('<?php echo U("AjaxRequest/updateFormContent");?>','<?php echo ($infoId); ?>','<?php echo ($formType); ?>',data.value,'<?php echo ($formData["form_name"]); ?>',$('input[name="<?php echo ($formType); ?>_form[<?php echo ($formData["form_name"]); ?>]"]'));
				})
			})

		</script><?php break;?>

	<?php case "select": ?><select name="<?php echo ($formType); ?>_form[<?php echo ($formData["form_name"]); ?>]" lay-filter="select-filter<?php echo ($t); ?>">

			<option value=""><?php echo ($formData["form_description"]); ?></option>

			<?php if(is_array($formData["option"])): foreach($formData["option"] as $key=>$op): ?><option value="<?php echo ($op); ?>" <?php if(($dataInfo['detail'][$formData[form_name]]) == $op): ?>selected<?php endif; ?>><?php echo ($op); ?></option><?php endforeach; endif; ?>

		</select>

		<script>

			layui.use(['form'],function()
			{
				var form = layui.form;

				form.on('select(select-filter<?php echo ($t); ?>)', function(data)
				{
					//updateFormContentAjax('<?php echo U("AjaxRequest/updateFormContent");?>','<?php echo ($infoId); ?>','<?php echo ($formType); ?>',data.value,'<?php echo ($formData["form_name"]); ?>',$('select[name="<?php echo ($formType); ?>_form[<?php echo ($formData["form_name"]); ?>]"]'));
				})
			})

		</script><?php break;?>

	<?php case "select_text": ?><!-- 下拉填写 -->
		<input type="text" name="<?php echo ($formType); ?>_form[<?php echo ($formData["form_name"]); ?>]" placeholder="" value="<?php echo ($dataInfo['detail'][$formData['form_name']]); ?>" readonly="readonly" class="layui-input cursor">

		<ul id="selectText<?php echo ($t); ?>" class="select-text" style="top:35px;">

			<?php if(is_array($formData["option"])): foreach($formData["option"] as $key=>$op): ?><li data-value="<?php echo ($op); ?>" <?php if(($dataInfo['detail'][$formData[form_name]]) == $op): ?>class="active"<?php endif; ?>><?php echo ($op); ?></li><?php endforeach; endif; ?>

		</ul>

		<script>

			$('input[name="<?php echo ($formType); ?>_form[<?php echo ($formData["form_name"]); ?>]"]').click(function ()
			{
				if($('#selectText<?php echo ($t); ?>').is(':hidden'))
				{
					$('#selectText<?php echo ($t); ?>').show();
				}
				else
				{
					$('#selectText<?php echo ($t); ?>').hide();
				}

				$('#selectText<?php echo ($t); ?> li').click(function ()
				{
					$('#selectText<?php echo ($t); ?> li').removeClass('active');
					var value = $(this).data('value');
					if(value == '其他')
					{
						$('input[name="<?php echo ($formType); ?>_form[<?php echo ($formData["form_name"]); ?>]"]').removeAttr("readonly");
						$('input[name="<?php echo ($formType); ?>_form[<?php echo ($formData["form_name"]); ?>]"]').val('');
						$('input[name="<?php echo ($formType); ?>_form[<?php echo ($formData["form_name"]); ?>]"]').focus();
					}
					else
					{
						$('input[name="<?php echo ($formType); ?>_form[<?php echo ($formData["form_name"]); ?>]"]').attr('readonly','readonly');
						$('input[name="<?php echo ($formType); ?>_form[<?php echo ($formData["form_name"]); ?>]"]').val(value);
					}
					$(this).addClass('active');
					$('#selectText<?php echo ($t); ?>').hide();
				})
			})

		</script><?php break;?>

	<?php case "region": ?><div class="region-input-div wd60 fl">

		<div class="layui-input-inline wd100 mb10 layui-form region-item <?php if(($crmsite["regionType"]) != "world"): ?>hidden<?php endif; ?>" lay-filter="country">

			<select name="<?php echo ($formType); ?>_form[<?php echo ($formData[form_name]); ?>_defaultCountry]" lay-filter="select-country<?php echo $reg; ?>" id="country<?php echo $reg; ?>" lay-ignore>

				<option value=""><?php echo L('PLEASE_SELECT');?></option>

				<?php if(is_array($country)): $i = 0; $__LIST__ = $country;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vc): $mod = ($i % 2 );++$i;?><option value="<?php echo ($vc["code"]); ?>" <?php if(($crmsite["regionType"]) != "world"): if(($vc["code"]) == "1"): ?>selected<?php endif; else: if(($dataInfo[$formData[form_name]]['defaultCountry']) == $vc["code"]): ?>selected<?php endif; endif; ?>><?php echo ($vc["name"]); ?></option><?php endforeach; endif; else: echo "" ;endif; ?>

			</select>

		</div>

		<div class="layui-input-inline wd100 mb10 <?php if(empty($dataInfo['detail'][$formData[form_name]]['defaultProv'])): if(($crmsite["regionType"]) == "world"): ?>hidden<?php endif; endif; ?> layui-form region-item" lay-filter="province">

			<select  name="<?php echo ($formType); ?>_form[<?php echo ($formData[form_name]); ?>_defaultProv]" lay-filter="select-province<?php echo $reg; ?>" id="province<?php echo $reg; ?>" lay-ignore>

				<option value=""><?php echo L('PLEASE_SELECT');?></option>

			</select>

		</div>

		<div class="layui-input-inline wd100 mb10 <?php if(empty($dataInfo['detail'][$formData[form_name]]['defaultCity'])): ?>hidden<?php endif; ?> layui-form region-item" lay-filter="city">

			<select  name="<?php echo ($formType); ?>_form[<?php echo ($formData[form_name]); ?>_defaultCity]" lay-filter="select-city<?php echo $reg; ?>" id="city<?php echo $reg; ?>" lay-ignore>

				<option value=""><?php echo L('PLEASE_SELECT');?></option>


			</select>

		</div>

		<div class="layui-input-inline wd100 mb10 <?php if(empty($dataInfo['detail'][$formData[form_name]]['defaultArea'])): ?>hidden<?php endif; ?> layui-form region-item" lay-filter="area">

			<select  name="<?php echo ($formType); ?>_form[<?php echo ($formData[form_name]); ?>_defaultArea]" lay-filter="select-area<?php echo $reg; ?>" id="area<?php echo $reg; ?>" lay-ignore>

				<option value=""><?php echo L('PLEASE_SELECT');?></option>


			</select>

		</div>

		</div>

		<i class="layui-icon layui-icon-about intro-icon fl blue8 ml10" data-note="<?php echo L('ENTER_NAME_SEARCH');?>"></i>

		<script type="text/javascript">

			<?php if(($crmsite["regionType"]) != "world"): if(empty($crmsite["regionType"])): ?>var defaultCountry<?php echo $reg; ?> = "<?php echo ($dataInfo[$formData[form_name]]['defaultCountry']); ?>";

				<?php else: ?>

					var defaultCountry<?php echo $reg; ?> = "1";<?php endif; ?>

			<?php else: ?>

				var defaultCountry<?php echo $reg; ?> = "<?php echo ($dataInfo[$formData[form_name]]['defaultCountry']); ?>";<?php endif; ?>

			<?php if(empty($dataInfo[$formData[form_name]]['defaultProv'])): if(($crmsite["regionType"]) != "world"): ?>var defaultProv<?php echo $reg; ?> = "<?php echo ($province); ?>";

				<?php else: ?>

					var defaultProv<?php echo $reg; ?> = "<?php echo ($dataInfo[$formData[form_name]]['defaultProv']); ?>";<?php endif; ?>

			<?php else: ?>

				var defaultProv<?php echo $reg; ?> = "<?php echo ($dataInfo[$formData[form_name]]['defaultProv']); ?>";<?php endif; ?>

			var defaultCity<?php echo $reg; ?> = "<?php echo ($dataInfo[$formData[form_name]]['defaultCity']); ?>";

			var defaultArea<?php echo $reg; ?> = "<?php echo ($dataInfo[$formData[form_name]]['defaultArea']); ?>";

			$("#country<?php echo $reg; ?>").select2();

			$("#province<?php echo $reg; ?>").select2();

			$("#city<?php echo $reg; ?>").select2();

			$("#area<?php echo $reg; ?>").select2();

			$("#country<?php echo $reg; ?>").change(function()
			{
				selectProvince('<?php echo $reg; ?>',"<?php echo U('AjaxRequest/getRegion');?>");

				var content = $(this).val();

				//updateFormContentAjax('<?php echo U("AjaxRequest/updateFormContent");?>','<?php echo ($infoId); ?>','<?php echo ($formType); ?>',content,'<?php echo ($formData["form_name"]); ?>',$(this).parent().parent(),"<?php echo ($formData['form_type']); ?>");
			})

			$("#province<?php echo $reg; ?>").change(function()
			{
				selectCity('<?php echo $reg; ?>',"<?php echo U('AjaxRequest/getRegion');?>");

				var country = $('select[name="<?php echo ($formType); ?>_form[<?php echo ($formData["form_name"]); ?>_defaultCountry]"]').val();

				var province = $(this).val();

				var content = country+','+province;

				//updateFormContentAjax('<?php echo U("AjaxRequest/updateFormContent");?>','<?php echo ($infoId); ?>','<?php echo ($formType); ?>',content,'<?php echo ($formData["form_name"]); ?>',$(this).parent().parent(),"<?php echo ($formData['form_type']); ?>");
			})

			$("#city<?php echo $reg; ?>").change(function()
			{
				selectArea('<?php echo $reg; ?>',"<?php echo U('AjaxRequest/getRegion');?>");

				var country = $('select[name="<?php echo ($formType); ?>_form[<?php echo ($formData["form_name"]); ?>_defaultCountry]"]').val();

				var province = $('select[name="<?php echo ($formType); ?>_form[<?php echo ($formData["form_name"]); ?>_defaultProv]"]').val();

				var city = $(this).val();

				var content = country+','+province+','+city;

				//updateFormContentAjax('<?php echo U("AjaxRequest/updateFormContent");?>','<?php echo ($infoId); ?>','<?php echo ($formType); ?>',content,'<?php echo ($formData["form_name"]); ?>',$(this).parent().parent(),"<?php echo ($formData['form_type']); ?>");
			})

			$("#area<?php echo $reg; ?>").change(function()
			{
				var country = $('select[name="<?php echo ($formType); ?>_form[<?php echo ($formData["form_name"]); ?>_defaultCountry]"]').val();

				var province = $('select[name="<?php echo ($formType); ?>_form[<?php echo ($formData["form_name"]); ?>_defaultProv]"]').val();

				var city = $('select[name="<?php echo ($formType); ?>_form[<?php echo ($formData["form_name"]); ?>_defaultCity]"]').val();

				var area = $(this).val();

				var content = country+','+province+','+city+','+area;

				//updateFormContentAjax('<?php echo U("AjaxRequest/updateFormContent");?>','<?php echo ($infoId); ?>','<?php echo ($formType); ?>',content,'<?php echo ($formData["form_name"]); ?>',$(this).parent().parent(),"<?php echo ($formData['form_type']); ?>");
			})

			if(defaultCountry<?php echo $reg; ?> && defaultProv<?php echo $reg; ?>)
			{
				$.post("<?php echo U('AjaxRequest/getRegion');?>",{country_id:defaultCountry<?php echo $reg; ?>,type:'province'},function(data)
				{
					if(data.code == 0)
					{
						var option = '<option value=""><?php echo L('SELECT_PROVINCE');?></option>';

						if(data.data.length > 0)
						{
							$.each(data.data,function(k,v)
							{
								if(defaultProv<?php echo $reg; ?>==v.code)
								{
									option += "<option c-value='"+ v.country_code+"' value='"+v.code+"' selected>"+v.name+"</option>";
								}
								else
								{
									option += "<option c-value='"+ v.country_code+"' value='"+v.code+"'>"+v.name+"</option>";
								}

							});

							$('#province<?php echo $reg; ?>').html(option).parents('.region-item').slideDown('fast');

							if(defaultProv<?php echo $reg; ?> && !defaultCity<?php echo $reg; ?>)
							{
								selectCity('<?php echo $reg; ?>',"<?php echo U('AjaxRequest/getRegion');?>");
							}
						}
						else
						{
							$('#province<?php echo $reg; ?>').html(option).parents('.region-item').slideUp('fast');
						}

						$("#province<?php echo $reg; ?>").select2();


					}
				});

				//$('#city<?php echo $reg; ?>').html('<option value=""><?php echo L('SELECT_CITY');?></option>').parents('.region-item').slideUp('fast');
			}
			else
			{
				selectProvince('<?php echo $reg; ?>',"<?php echo U('AjaxRequest/getRegion');?>");
			}

			if(defaultCountry<?php echo $reg; ?> && defaultProv<?php echo $reg; ?> && defaultCity<?php echo $reg; ?>)
			{
				$.post("<?php echo U('AjaxRequest/getRegion');?>",{country_id:defaultCountry<?php echo $reg; ?>,province_id:defaultProv<?php echo $reg; ?>,type:'city'},function(data)
				{
					if(data.code == 0)
					{
						var option = '<option value=""><?php echo L('SELECT_CITY');?></option>';

						if(data.data.length > 0)
						{
							$.each(data.data,function(k,v)
							{
								if(defaultCity<?php echo $reg; ?>==v.code)
								{
									option += "<option c-value='"+ v.country_code+"' p-value='"+ v.province_code+"' value='"+v.code+"' selected>"+v.name+"</option>";
								}
								else
								{
									option += "<option c-value='"+ v.country_code+"' p-value='"+ v.province_code+"' value='"+v.code+"'>"+v.name+"</option>";
								}
							});

							$('#city<?php echo $reg; ?>').html(option).parents('.region-item').slideDown('fast');

							if(defaultCity<?php echo $reg; ?> && !defaultArea<?php echo $reg; ?>)
							{
								selectArea('<?php echo $reg; ?>',"<?php echo U('AjaxRequest/getRegion');?>");
							}
						}
						else
						{
							$('#city<?php echo $reg; ?>').html(option).parents('.region-item').slideUp('fast');
						}

						$("#city<?php echo $reg; ?>").select2();
					}
				});
			}

			if(defaultCountry<?php echo $reg; ?> && defaultProv<?php echo $reg; ?> && defaultCity<?php echo $reg; ?> && defaultArea<?php echo $reg; ?>)
			{
				$.post("<?php echo U('AjaxRequest/getRegion');?>",{country_id:defaultCountry<?php echo $reg; ?>,province_id:defaultProv<?php echo $reg; ?>,city_id:defaultCity<?php echo $reg; ?>,type:'area'},function(data)
				{
					if(data.code == 0)
					{
						var option = '<option value=""><?php echo L('SELECT_AREA');?></option>';

						if(data.data.length > 0)
						{
							$.each(data.data,function(k,v)
							{
								if(defaultArea<?php echo $reg; ?>==v.code)
								{
									option += "<option value='"+v.code+"' selected>"+v.name+"</option>";
								}
								else
								{
									option += "<option value='"+v.code+"'>"+v.name+"</option>";
								}
							});

							$('#area<?php echo $reg; ?>').html(option).parents('.region-item').slideDown('fast');
						}
						else
						{
							$('#area<?php echo $reg; ?>').html(option).parents('.region-item').slideUp('fast');
						}

						$("#area<?php echo $reg; ?>").select2();
					}
				});
			}

		</script><?php break; endswitch;?>

<?php else: ?>

<span class="fl"><?php echo ((isset($dataInfo['detail'][$formData['form_name']]) && ($dataInfo['detail'][$formData['form_name']] !== ""))?($dataInfo['detail'][$formData['form_name']]):'--'); ?></span>

	<?php if(($formData["form_type"]) == "region"): ?><input type="hidden" name="<?php echo ($formType); ?>_form[<?php echo ($formData["form_name"]); ?>_defaultCountry]" value="<?php echo ($dataInfo[$formData['form_name']]['defaultCountry']); ?>" >
		<input type="hidden" name="<?php echo ($formType); ?>_form[<?php echo ($formData["form_name"]); ?>_defaultProv]" value="<?php echo ($dataInfo[$formData['form_name']]['defaultProv']); ?>" >
		<input type="hidden" name="<?php echo ($formType); ?>_form[<?php echo ($formData["form_name"]); ?>_defaultCity]" value="<?php echo ($dataInfo[$formData['form_name']]['defaultCity']); ?>" >
		<input type="hidden" name="<?php echo ($formType); ?>_form[<?php echo ($formData["form_name"]); ?>_defaultArea]" value="<?php echo ($dataInfo[$formData['form_name']]['defaultArea']); ?>" >

	<?php else: ?>
		<input type="hidden" name="<?php echo ($formType); ?>_form[<?php echo ($formData["form_name"]); ?>]" value="<?php echo ($dataInfo['detail'][$formData['form_name']]); ?>" /><?php endif; endif; ?>